﻿using System;

namespace RaceList.Admin.Relay
{
    public class CommonHelp
    {
        public static bool GetStatus(int selectedIndex)
        {
            var status = false;
            if (selectedIndex == 0)
            {
                status = true;
            }
            else
            {
                status = false;
            }
            return status;
        }

        public static int GetSelectIndex(bool status)
        {
            var result = 1;
            if (status == true)
            {
                result = 0;
            }

            return result;
        }

        /// <summary>
        /// 这个返回值写的不错
        /// </summary>
        /// <returns></returns>
        public static int? GetSponsor(string selectedValue)
        {
            try
            {
                var result = Convert.ToInt32(selectedValue);
                return result;
            }
            catch
            {
                return null;
            }
        }

        public static string CheckStatus(object status)
        {
            if (status != null)
            {
                try
                {
                    var obj = Convert.ToBoolean(status);

                    if (obj == true)
                    {
                        return "<font color=\"green\">已启用，点击禁用</font>";
                    }
                }
                catch
                {
                    return "<font color=\"red\">已禁用,点击启用</font>";
                }
            }

            return "<font color=\"red\">已禁用,点击启用</font>";
        }
        /// <summary>
        /// 核对发放奖品
        /// </summary>
        /// <returns></returns>
        public static string CheckAward(object isCheck)
        {
            if (isCheck != null)
            {
                try
                {
                    var obj = Convert.ToBoolean(isCheck);

                    if (obj)
                    {
                        return "<font color=\"green\">已兑奖</font>";
                    }
                }
                catch
                {
                    return "<font color=\"red\">未兑奖</font>";
                }
            }

            return "<font color=\"red\">未兑奖</font>";
        }
    }
}